import pandas as pd
from flask import Flask, render_template_string, request

app = Flask(__name__)

HTML_TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
    <title>Excel Data Viewer</title>
</head>
<body>
    <h2>Upload Excel File</h2>
    <form method="post" enctype="multipart/form-data">
        <input type="file" name="excel_file" accept=".xlsx,.xls">
        <input type="submit" value="Upload">
    </form>
    {% if tables %}
        <h2>Excel Data</h2>
        {{ tables|safe }}
    {% endif %}
</body>
</html>
"""

@app.route('/', methods=['GET', 'POST'])
def index():
    tables = None
    if request.method == 'POST':
        file = request.files.get('excel_file')
        if file:
            df = pd.read_excel(file)
            tables = df.to_html(classes='table table-striped', index=False)
    return render_template_string(HTML_TEMPLATE, tables=tables)

if __name__ == '__main__':
    app.run(debug=True)
    print